<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package}.${moduleName}.mapper${className}Mapper">

    <#if enableCache>
        <!-- 开启二级缓存 -->
        <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>

    </#if>
    <#if baseResultMap>
        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="${package}.${moduleName}.domain.${className}">
            <#if columns??>
                <#list columns as field>
                    <#if field.columnKey = 'PRI'>
                    <#--生成主键排在第一位-->
                        <id column="${field.columnName}" property="${field.changeColumnName}"/>
                    </#if>
                </#list>
                <#list columns as field>
                    <#if field.columnKey != 'PRI'><#--生成普通字段 -->
                        <result column="${field.columnName}" property="${field.changeColumnName}"/>
                    </#if>
                </#list>
            </#if>
        </resultMap>
    </#if>

    <#if baseColumnList>
        <sql id="Base_Column_List">
            <#if columns??>
                <#list columns as field>
                    ${field.columnName},
                </#list>
                ${tableName}
            </#if>
        </sql>
    </#if>

    <sql id="condition">
        <#if columns??>
        <#list columns as field>
        <#if field.columnType =='String'>
        <if test="search.${field.changeColumnName} is not null and search.${field.changeColumnName} !=''"><#else>
            <if test="search.${field.changeColumnName} is not null"></#if>
                AND ${tableName}.${field.columnName} = <#noparse>#{</#noparse>search.${field.changeColumnName}}
            </if>
            </#list>
            </#if>
    </sql>

</mapper>
